<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8"/>
    <title>显示隐藏</title>
<style>
    #div1{
        width:100px;height:200px;background:red;display:none;
    }
</style>
</head>
<script>
    
    function showHide(){
        //要操作div1，先选中它
        var oDiv = document.getElementById('div1');
        //判断
        //当div1是显示的，点击他则隐藏
        //当div1是隐藏的，点击他则显示
        if(oDiv.style.display == 'block'){
            oDiv.style.display = 'none';
        }else{
            oDiv.style.display = 'block';
        }
    }

</script>
<body>
    <input type="button"  value="显示隐藏"  onclick="showHide()"/>
    <div id="div1"></div>
</body>
</html>

